//package com.usermanage.ExceptionConfig;
//
//import com.usermanage.util.JsonData;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.security.authentication.BadCredentialsException;
//import org.springframework.web.servlet.HandlerExceptionResolver;
//import org.springframework.web.servlet.ModelAndView;
//import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * Created by 過客 on 2018/3/9
// * 全局异常处理类
// */
//@Slf4j
//public class SpringExceptionResolver implements HandlerExceptionResolver {
//    @Override
//    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
//        log.error(e.getMessage());
////        String url = httpServletRequest.getRequestURL().toString();//获得请求得url
//        ModelAndView mv;
//        String defaultMsg = "System error";  //默认异常信息
//        JsonData result;
//        MappingJackson2JsonView jsonView = new MappingJackson2JsonView();
//        if (e instanceof BadCredentialsException){
//            result = JsonData.fail("用户名或密码错误！");
//        }else{
//            result = JsonData.fail(e.getMessage());
//        }
//        mv = new ModelAndView(jsonView, result.errMap());
//        return mv;
//    }
//
//
//}
